<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <script>
      var arr = [2, 7, 1, 4, 6]
      var sum = 0
      var average = 0
      for (var i = 0; i < arr.length; i++) {
        sum += arr[i]
      }
      average = sum / arr.length
      console.log(sum, average)
    </script>
  </body>
</html>
